using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace EuropeEngulfed.NET
{
    partial class ViewGameHistoryDialog : Form
    {
        public static Size TREE_IMAGE_SIZE = new Size(25,25);
        public ViewGameHistoryDialog(Dictionary<GameTurn.GameDate, Dictionary<GameTurn.GamePhase, Dictionary<GameTurn.GameSubPhase, List<Move>>>> listOfMoves)
        {
            InitializeComponent();

            System.Reflection.Assembly thisExe;
            thisExe = System.Reflection.Assembly.GetExecutingAssembly();
            System.IO.Stream file;
            file = thisExe.GetManifestResourceStream("EuropeEngulfed.NET.Resources.move.png");

            this.gameMovesTreeView.ImageList = new ImageList();
            this.gameMovesTreeView.ImageList.ImageSize = TREE_IMAGE_SIZE;
            this.gameMovesTreeView.ImageList.Images.Add((Bitmap)Bitmap.FromStream(file));
            foreach(GameTurn.GameDate gameDate in listOfMoves.Keys)
            {
                TreeNode gameDateTreeNode = new TreeNode(GameTurn.GameDateToString(gameDate));
                this.gameMovesTreeView.Nodes.Add(gameDateTreeNode);
                foreach(GameTurn.GamePhase gamePhase in listOfMoves[gameDate].Keys)
                {
                    TreeNode gamePhaseTreeNode = new TreeNode(GameTurn.GamePhaseToString(gamePhase));
                    gameDateTreeNode.Nodes.Add(gamePhaseTreeNode);
                    foreach(GameTurn.GameSubPhase gameSubPhase in listOfMoves[gameDate][gamePhase].Keys)
                    {
                        TreeNode gameSubPhaseTreeNode = new TreeNode(GameTurn.GameSubPhaseToString(gameSubPhase));
                        gamePhaseTreeNode.Nodes.Add(gameSubPhaseTreeNode);
                        foreach (Move move in listOfMoves[gameDate][gamePhase][gameSubPhase])
                        {
                            gameSubPhaseTreeNode.Nodes.Add(move.GetMoveTreeNode(this.gameMovesTreeView));
                        }
                    }
                }
            }
        }

        private void OkButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}